﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:my="clr-namespace:HelpDesk.Commands"
             xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
             xmlns:r="clr-namespace:System;assembly=mscorlib"
             xmlns:ViewModel="clr-namespace:HelpDesk.ViewModel"
             xmlns:local="clr-namespace:HelpDesk.UserControls"
             x:Class="HelpDesk.UserControls.ActiveDirectory2"
             mc:Ignorable="d"
             d:DesignHeight="400"
             d:DesignWidth="800"
             Loaded="UserControl_Loaded"
             Unloaded="UserControl_Unloaded">
    <UserControl.DataContext>
        <ViewModel:ActiveDirectoryViewModel  MessageBus="{StaticResource APPMessageBus}" />
    </UserControl.DataContext>
    <StackPanel LostFocus="StackPanel_LostFocus">
        <Grid Margin="5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="217" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <TextBlock Text="Admin User"
                       Margin="0,7,10,4" />
            <TextBox x:Name="txt_AdminUser"
                     Margin="3"
                     Grid.Row="0"
                     Grid.Column="1"
                     Text="{my:SettingBinding txt_AdminUser}" />

            <TextBlock Text="Admin Password"
                       Margin="0,7,10,3"
                       Grid.Row="1" />
            <PasswordBox x:Name="txt_AdminPassword"
                         Margin="3"
                         Grid.Row="1"
                         Grid.Column="1" />

            <TextBlock Text="Domain"
                       Margin="0,7,10,3"
                       Grid.Row="2" />
            <TextBox x:Name="txt_Domain"
                     Margin="3"
                     Grid.Row="2"
                     Grid.Column="1"
                     Text="{my:SettingBinding txt_Domain}" />

            <TextBlock Text="Computer"
                       Margin="0,7,10,3"
                       Grid.Row="3"
                       Style="{StaticResource DesignerWhiteForegroundStyle}" />
            <TextBox x:Name="txt_ComputerSyntax"
                     Margin="3"
                     Grid.Row="3"
                     Grid.Column="1"
                     Text="{my:SettingBinding txt_ComputerSyntax}" />
            <TextBlock Text="User Prefix"
                       Margin="0,7,10,3"
                       Grid.Row="4"
                       Visibility="Visible"
                       Style="{StaticResource DesignerWhiteForegroundStyle}" />
            <TextBox x:Name="txt_UserName"
                     Margin="3"
                     Grid.Row="4"
                     Grid.Column="1"
                     Text="{}{userName}"
                     Visibility="Visible" />
            <TextBlock Text="Password Prefix"
                       Margin="0,7,10,3"
                       Grid.Row="5"
                       Visibility="Visible"
                       Style="{StaticResource DesignerWhiteForegroundStyle}" />
            <TextBox x:Name="txt_prefixPassword"
                     Margin="3"
                     Grid.Row="5"
                     Grid.Column="1"
                     Text="{my:SettingBinding txt_prefixPassword}"
                     Visibility="Visible" />

            <TextBlock Text="User ComboBox Prefix"
                       Margin="0,7,10,3"
                       Grid.Row="7"
                       Visibility="Visible"
                       Style="{StaticResource DesignerWhiteForegroundStyle}"
                       ToolTip="If you need the selected user from ComboBox Users" />
            <TextBox x:Name="txt_UserComboBoxPrefix"
                     Margin="3"
                     Grid.Row="7"
                     Grid.Column="1"
                     Text="{}{comboboxUserName}"
                     Visibility="Visible" />

            <ListBox ItemsSource="{Binding ObDistinguishedNames}"
                     x:Name="level1Lister"
                     Grid.Row="8"
                     Grid.ColumnSpan="2"
                     MinHeight="100"
                     dd:DragDrop.IsDragSource="True"
                     dd:DragDrop.IsDropTarget="True"
                     IsSynchronizedWithCurrentItem="True">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Border Height="Auto"
                                Margin="5"
                                Width="Auto"
                                BorderBrush="Black"
                                CornerRadius="3"
                                BorderThickness="1,1,2,1">
                            <Grid d:DesignWidth="483.528"
                                  d:DesignHeight="93.92"
                                  Margin="0,1"
                                  HorizontalAlignment="Left"
                                  Width="648.528">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="207" />
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="Auto"
                                                      MinWidth="39.528" />
                                </Grid.ColumnDefinitions>

                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto"
                                                   MinHeight="15.96" />
                                    <RowDefinition Height="0*" />
                                </Grid.RowDefinitions>

                                <!--ProgramPath-->
                                <TextBlock Margin="3,7,10,4"
                                           Text="Computers DistinguishedName OU" />
                                <TextBox x:Name="txt_ComputersDistinguishedNameOU"
                                         Margin="0,7,10,4"
                                         Grid.Row="0"
                                         Grid.Column="1"
                                         Width="Auto"
                                         HorizontalAlignment="Stretch"
                                         Text="{Binding Computers, UpdateSourceTrigger=PropertyChanged}" />

                                <!--Options-->
                                <TextBlock Text="Users DistinguishedName OU"
                                           Margin="3,7,10,4"
                                           Grid.Row="1" />
                                <TextBox x:Name="txt_UsersDistinguishedNameOU"
                                         Margin="0,7,10,4"
                                         Grid.Row="1"
                                         Grid.Column="1"
                                         Width="Auto"
                                         HorizontalAlignment="Stretch"
                                         Text="{Binding Users}" />

                                <!--btnBrows-->

                                <!--Default-->

                                <!--Add Or Remove-->
                                <StackPanel Grid.Column="2"
                                            HorizontalAlignment="Center"
                                            Height="28"
                                            Margin="0"
                                            Grid.RowSpan="1"
                                            VerticalAlignment="Center"
                                            Width="37.025"
                                            Orientation="Horizontal">
                                    <Button x:Name="btnAdd"
                                            Content="+"
                                            Margin="0,5.02"
                                            Height="17.96"
                                            Tag="{Binding Index}"
                                            Command="{Binding DataContext.AddDistinguishedNames, ElementName=level1Lister}"
                                            CommandParameter="{Binding}" />
                                    <Button x:Name="btnRemove"
                                            Content="-"
                                            Margin="5,5.02,23.667,5.02"
                                            Height="17.96"
                                            Width="14.8"
                                            Command="{Binding DataContext.RemoveDistinguishedNames, ElementName=level1Lister}"
                                            CommandParameter="{Binding}"
                                            Tag="{Binding}" />
                                </StackPanel>

                                <!--Printers DistinguishedName OU-->
                                <TextBlock HorizontalAlignment="Stretch"
                                           TextWrapping="Wrap"
                                           Text="Printers DistinguishedName OU"
                                           VerticalAlignment="Top"
                                           Grid.Row="2"
                                           Height="15.96"
                                           Width="Auto"
                                           Margin="3,7,10,4"
                                           Grid.ColumnSpan="1" />
                                <TextBox x:Name="txtButtonName"
                                         Margin="0,7,10,4"
                                         Grid.Row="2"
                                         Grid.Column="1"
                                         Width="Auto"
                                         HorizontalAlignment="Stretch"
                                         Text="{Binding Printers, NotifyOnSourceUpdated=True}" />
                                <TextBlock Grid.Column="2"
                                           HorizontalAlignment="Center"
                                           Height="20"
                                           Margin="10,7,0,0"
                                           Grid.Row="2"
                                           TextWrapping="Wrap"
                                           Text="{Binding Index}"
                                           VerticalAlignment="Center"
                                           Width="20" />

                            </Grid>
                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>


            <TextBlock Text="Sync with Active Directory"
                       Margin="0,7,10,3"
                       Grid.Row="9"
                       Visibility="Visible"
                       Style="{StaticResource DesignerWhiteForegroundStyle}" />

            <!--Checked="StackPanel_Checked"
                Unchecked="StackPanel_Checked"-->

            <StackPanel Grid.Row="9"
                        Grid.Column="1"
                        Orientation="Horizontal">
                <CheckBox Content="Computers"
                          Margin="5"
                          x:Name="CheckComputers"
                          Tag="1"
                          Command="{Binding ActiveDirectoryComputers,NotifyOnSourceUpdated=True,Mode=TwoWay}"
                          CommandParameter="{Binding Mode=OneWay, RelativeSource={RelativeSource Self}}"
                          IsChecked="{my:SettingBinding CheckComputers}" />
                <CheckBox Content="Users"
                          Margin="5"
                          x:Name="CheckUsers"
                          Tag="2"
                          Command="{Binding ActiveDirectoryUsers,NotifyOnSourceUpdated=True,Mode=TwoWay}"
                          CommandParameter="{Binding Mode=OneWay, RelativeSource={RelativeSource Self}}"
                          IsChecked="{my:SettingBinding CheckUsers}" />
                <CheckBox Content="Printers"
                          Margin="5"
                          x:Name="CheckPrinters"
                          Tag="3"
                          Command="{Binding ActiveDirectoryPrinters,NotifyOnSourceUpdated=True,Mode=TwoWay}"
                          CommandParameter="{Binding Mode=OneWay, RelativeSource={RelativeSource Self}}"
                          IsChecked="{my:SettingBinding CheckPrinters}" />


            </StackPanel>
        </Grid>
    </StackPanel>
</UserControl>
